package org.hilo.boot.app.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

import org.hilo.boot.core.web.xss.XssFilter;

/**
 * 
 * @author zollty
 * @since 2019年1月25日
 */
@Configuration
@ConditionalOnProperty(prefix = "hilo.web.filter", name = "xss")
public class XssFilterConfig implements BaseFilterConfig {
    // 次高的优先级
    private int order = Ordered.HIGHEST_PRECEDENCE + 1000;
    
    @Bean
    public FilterRegistrationBean<XssFilter> xssFilterRegistration() {
        FilterRegistrationBean<XssFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new XssFilter());
        registration.setName("App_xssFilter");
        registration.addUrlPatterns("/*");
        registration.setOrder(order);
        return registration;
    }
    
}
